.TH std::filesystem::directory_entry::path 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::filesystem::directory_entry::path \- std::filesystem::directory_entry::path

.SH Synopsis
   const std::filesystem::path& path() const noexcept;       \fI(since C++17)\fP
   operator const std::filesystem::path& () const noexcept;  \fI(since C++17)\fP

   Returns the full path the directory entry refers to.

.SH Parameters

   \fI(none)\fP

.SH Return value

   The full path the directory entry refers to.

.SH Example


// Run this code

 #include <filesystem>
 #include <fstream>
 #include <iostream>

 namespace fs = std::filesystem;

 std::string get_stem(const fs::path& p) { return p.stem().string(); }
 void create_file(const fs::path& p) { std::ofstream o{p}; }

 int main()
 {
     const fs::path dir{"tmp_dir"};
     fs::create_directory(dir);
     create_file(dir / "one");
     create_file(dir / "two");
     create_file(dir / "three");

     for (const auto& file : fs::directory_iterator(dir))
     {
         // Explicit conversion
         std::cout << get_stem(file.path()) << '\\n';

         // Implicit conversion
         std::cout << get_stem(file) << '\\n';
     }

     fs::remove_all(dir);
 }

.SH Possible output:

 two
 two
 one
 one
 three
 three

.SH See also

   path    represents a path
   \fI(C++17)\fP \fI(class)\fP
